package models

type ResCode int32

// 定义错误码与消息
const (
	//用户
	CodeSuccess      = 0
	CodeInvalidParam = 1000 + iota
	CodeUserExist
	CodeUserNotExist
	CodeInvalidPassword
	CodeServerBusy
	CodeNeedLogin
	CodeInvalidToken
	//视频
	CodeUploadVideoError
	CodeGetVideoStreamError
	CodeGetVideoFeedError
	CodeGetVideoListError
	CodeFavoriteActionError
	//评论
	CodeCommentError
	CodeGetVideoCommentsError
	//关系
	CodeRelationActionError
	CodeGetFollowListError
	CodeGetFollowerListError
)

var codeMsgMap = map[ResCode]string{
	CodeSuccess:               "success",
	CodeInvalidParam:          "请求参数错误",
	CodeUserExist:             "用户名已存在",
	CodeUserNotExist:          "用户名不存在",
	CodeInvalidPassword:       "用户名或密码错误",
	CodeServerBusy:            "服务繁忙",
	CodeNeedLogin:             "需要登录",
	CodeInvalidToken:          "无效的token",
	CodeUploadVideoError:      "上传视频错误",
	CodeGetVideoStreamError:   "获取视频流错误",
	CodeGetVideoListError:     "获取视频列表错误",
	CodeGetVideoFeedError:     "获取视频feed流错误",
	CodeFavoriteActionError:   "视频赞操作错误",
	CodeCommentError:          "视频评论操作错误",
	CodeGetVideoCommentsError: "获取视频评论错误",
	CodeRelationActionError:   "关注/取关操作错误",
	CodeGetFollowListError:    "获取关注列表错误",
	CodeGetFollowerListError:  "获取粉丝列表错误",
}

func (c ResCode) Msg() string {
	msg, ok := codeMsgMap[c]
	if !ok {
		msg = codeMsgMap[CodeServerBusy]
	}
	return msg
}
